package com.dcw.lixb.designmode.filter;

import java.util.ArrayList;
import java.util.List;

/**
 * @author lixiaobin
 * @date 2020-07-21 15:35:25
 * @desc 描述信息
 */
public class FilterMain {

    public static final String MARRIED = "Married";
    public static final String SINGLE = "Single";
    public static final String MALE = "male";
    public static final String FEMALE = "female";

    public static void main(String[] args) {
        List<Person> personList = new ArrayList<>();
        personList.add(new Person("张三", MALE, MARRIED));
        personList.add(new Person("李四", FEMALE, SINGLE));
        personList.add(new Person("王五", MALE, SINGLE));
        personList.add(new Person("赵柳", FEMALE, SINGLE));
        personList.add(new Person("黄吧", MALE, SINGLE));
        personList.add(new Person("刘久", MALE, SINGLE));
        personList.add(new Person("刘德华", MALE, MARRIED));
        personList.add(new Person("王祖贤", FEMALE, SINGLE));
        personList.add(new Person("周慧敏", FEMALE, SINGLE));
        personList.add(new Person("小乔", FEMALE, MARRIED));


        CriteriaMale criteriaMale = new CriteriaMale();
        List<Person> personList1 = criteriaMale.meetCriteria(personList);
        System.out.println("male : "+personList1);

        CriteriaFemale criteriaFemale = new CriteriaFemale();
        List<Person> personList2 = criteriaFemale.meetCriteria(personList);
        System.out.println("female : "+personList2);

        CriteriaSingle criteriaSingle = new CriteriaSingle();
        List<Person> personList3 = criteriaSingle.meetCriteria(personList);
        System.out.println("single : "+personList3);

        AndCriteria andCriteria = new AndCriteria(criteriaFemale, criteriaSingle);
        List<Person> personList4 = andCriteria.meetCriteria(personList);
        System.out.println("and : " + personList4);

        OrCriteria orCriteria = new OrCriteria(criteriaFemale, criteriaSingle);
        List<Person> personList5 = orCriteria.meetCriteria(personList);
        System.out.println("or : "+personList5);

    }
}
